package com.example.demo;

import java.sql.SQLException;
import java.util.List;

import static tools.print.pln;

public class Author {

    private Author(){}

    //查询该作者所有文章
    public static List init(String msg) throws SQLException {
        pln(msg);
        List list = null;
        //自然连接两张表，获取该作者及其所有文章的所有信息
        list = Connector.query("select * from author natural join post where name ='"+msg+"'");
        return list;
    }

    //上传评论
    public static List commit(String msg) throws SQLException {
        pln(msg);
        List list = null;
        Connector.insert("insert into test(name) values ('"+msg+"')");
        list = Connector.query("select * from test");
        return list;
    }

    //删除评论
    public static List del(String msg) throws SQLException {
        pln(msg);
        List list = null;
        pln("delete from test where id ="+msg);
        Connector.delete("delete from test where id ="+msg);
        list = Connector.query("select * from test");
        return list;
    }

}
